Global settings for w2ui

<div class="definition">
    Object
</div>

There is a number of default settings used across w2ui library (grid, form, tooltip, toolbar, etc). The setting object is a map with the following structure:


<textarea class="javascript">
settings : {
    locale            : "en-us",
    dateFormat        : "mm/dd/yyyy",
    timeFormat        : "hh:mi pm",
    currencyPrefix    : "$",
    currencySuffix    : "",
    currencyPrecision : 2,
    groupSymbol       : ",",
    decimalSymbol     : ".",
    shortmonths       : ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],
    fullmonths        : ["January", "February", "March", "April", "May", "June", "July", "August",
                            "September", "October", "November", "December"],
    shortdays         : ["M", "T", "W", "T", "F", "S","S"],
    fulldays          : ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
                            "Saturday", "Sunday"],
    weekStarts        : "M",     // can be "M" for Monday or "S" for Sunday
    dataType          : 'JSON',  // can be JSON, HTTP, RESTFULL
    phrases           : {}       // empty object for phrases
    warnNoPhrase      : true,    // warns if a phrase translation is missing
    dateStartYear     : 1950,    // start year for date-picker
    dateEndYear       : 2020     // end year for date picker
}
</textarea>

You can define and load settings based on your locale. See <a class="method" href="w2utils.locale">.locale()</a> method
for more information. All locale specific files are located in <a href="https://github.com/vitmalina/w2ui/tree/master/src/locale">/src/locale</a> folder.
<div style="height: 20px"></div>

<h4>Data Types</h4>

w2utils.settings<span class="property">.dataType</span> can be one of the following.
<div style="height: 20px"></div>

<b>JSON</b> (default) - will encode params as a JSON string and will submit GET request for most of the actions in grid, forms, remote drop down, except for the form save, which will be submitted as POST. The body of the POST request will be encoded as JSON. For w2grid the GET request will look like this:
<textarea class="javascript">
request: {
    "limit":100,
    "offset":0,
    "searchLogic":"AND",
    "search":[
        {"field":"age", "type":"int", "operator":"between", "value":[10,20]},
        {"field":"fname", "type":"text", "operator":"begins", "value":"vitali"}
    ],
    "sort":[
        {"field":"fname", "direction":"asc"},
        {"field":"lname", "direction":"asc"}
    ]
}
</textarea>
<div style="height: 20px"></div>

<b>HTTP</b> - will encode params as HTTP string and will submit GET request, except form save, that will be submitted as POST. The body of the POST request will be encoded as JSON. For the grid the GET request will look like this:
<textarea class="javascript">
limit: 100
&offset: 0
&searchLogic: AND
&search[0][field]: age
&search[0][type]: int
&search[0][operator]: between
&search[0][value][]: 10
&search[0][value][]: 20
&search[1][field]: fname
&search[1][type]: text
&search[1][operator]: begins
&search[1][value]: vitali
&sort[0][field]: fname
&sort[0][direction]: asc
&sort[1][field]: lname
&sort[1][direction]: asc
</textarea>
<div style="height: 20px"></div>

<b>RESTFULL</b> - will encode params as HTTP string and will submit GET for list, PUT for save, DELETE for delete, POST for update actions in w2grid and w2forms. The body of the POST, PUT, DELETE requests will be encoded as JSON. You can use RESTFULLJSON to encode GET requests with JSON. For w2grid the GET request will look like this:
<textarea  class="javascript">
limit: 100
&offset: 0
&searchLogic: AND
&search[0][field]: age
&search[0][type]: int
&search[0][operator]: between
&search[0][value][]: 10
&search[0][value][]: 20
&search[1][field]: fname
&search[1][type]: text
&search[1][operator]: begins
&search[1][value]: vitali
&sort[0][field]: fname
&sort[0][direction]: asc
&sort[1][field]: lname
&sort[1][direction]: asc
</textarea>
<div style="height: 20px"></div>

<b>dataType</b> can also be a JavaScript function. If it is a function, it will receive (url, fetchOptions, options) as arguments and it must return fetchOptions. This fetchOptions will be used in the browser fetch() call. This way you can fully customize how the request will be sent to the server.
